package Server.entity;

import lombok.Data;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;

/**
 * Entity - 购物车
 *
 * @author xvzhe
 * @version 0.1
 *
 */
@Data
@Entity
@EntityListeners(AuditingEntityListener.class)
@DynamicInsert
@DynamicUpdate
public class ShopCar {

    @Id
    @GeneratedValue(generator = "NumberIdProduce")
    @GenericGenerator(name="NumberIdProduce", strategy="Server.tool.NumberIdProduce")
    private String uuid;

    @CreatedDate
    @Column
    private Date createTime;

    @LastModifiedDate
    @Column
    private Date modifiedTime;

    /*
    *
    * 商品
    *
    * */
    @ManyToOne
    @JoinColumn(name = "shopSpecId")
    private  ShopSpec shopSpec;
    /*
    *
    * 用户
    *
    * */
    @ManyToOne
    @JoinColumn(name = "userId")
    private  Users users;



    @Column(columnDefinition="tinyint default 1")
    private Integer count;

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getModifiedTime() {
        return modifiedTime;
    }

    public void setModifiedTime(Date modifiedTime) {
        this.modifiedTime = modifiedTime;
    }

    public ShopSpec getShopSpec() {
        return shopSpec;
    }

    public void setShopSpec(ShopSpec shopSpec) {
        this.shopSpec = shopSpec;
    }

    public Users getUsers() {
        return users;
    }

    public void setUsers(Users users) {
        this.users = users;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

}
